/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.itbaizhan.addpanel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Vector;

import javax.swing.JOptionPane;
import javax.swing.border.MatteBorder;

import cn.itbaizhan.dao.CarDAO;
import cn.itbaizhan.entity.CarEntity;
import cn.itbaizhan.swing.CarManagePanel;
import cn.itbaizhan.tool.Chooser;

/**
 *
 * @author Administrator
 */
public class CarCorJFrame1 extends javax.swing.JFrame {

    /**
     * Creates new form NewJFrame
     */
    public CarCorJFrame1() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        // 创建UI组件：标签和输入控件
        jLabel1 = new javax.swing.JLabel(); // 用于显示文本的标签
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox(); // 下拉选择框
        jButton1 = new javax.swing.JButton(); // 按钮
        jComboBox2 = new javax.swing.JComboBox(); // 另一个下拉选择框
        jButton2 = new javax.swing.JButton(); // 另一个按钮
        jButton3 = new javax.swing.JButton(); // 第三个按钮
        jTextField1 = new javax.swing.JTextField(); // 文本输入框
        jTextField2 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        jTextField6 = new javax.swing.JTextField();
        jTextField7 = new javax.swing.JTextField();


        // 设置背景颜色、前景颜色以及 jTextField1 的可见性
        setBackground(new java.awt.Color(255, 255, 255));
        setForeground(java.awt.Color.white);
        jTextField1.setVisible(false);

        // 设置标签的字体、文本、前景颜色及首选尺寸
        jLabel2.setFont(new java.awt.Font("宋体", 0, 14)); // 设置字体为宋体，字号为14
        jLabel2.setText("车牌号:");
        jLabel2.setForeground(new java.awt.Color(255, 51, 0)); // 设置文本颜色
        jLabel2.setPreferredSize(new java.awt.Dimension(36, 25)); // 设置标签的尺寸

        jLabel4.setFont(new java.awt.Font("宋体", 0, 14));
        jLabel4.setText("品牌型号:");
        jLabel4.setPreferredSize(new java.awt.Dimension(36, 25));

        jLabel5.setFont(new java.awt.Font("宋体", 0, 14));
        jLabel5.setText("车辆类型:");
        jLabel5.setPreferredSize(new java.awt.Dimension(36, 25));

        jLabel6.setFont(new java.awt.Font("宋体", 0, 14));
        jLabel6.setText("发动机号:");
        jLabel6.setPreferredSize(new java.awt.Dimension(36, 25));

        jLabel7.setFont(new java.awt.Font("宋体", 0, 14));
        jLabel7.setText("车架号:");
        jLabel7.setPreferredSize(new java.awt.Dimension(36, 25));

        jLabel8.setFont(new java.awt.Font("宋体", 0, 14));
        jLabel8.setText("购入日期:");
        jLabel8.setPreferredSize(new java.awt.Dimension(36, 25));

        jLabel9.setFont(new java.awt.Font("宋体", 0, 14));
        jLabel9.setText("车辆状态:");
        jLabel9.setPreferredSize(new java.awt.Dimension(36, 25));

        jLabel10.setFont(new java.awt.Font("宋体", 0, 14));
        jLabel10.setText("备注:");
        jLabel10.setPreferredSize(new java.awt.Dimension(36, 25));

        // 设置 jComboBox1 的字体和项目，以及添加项目时的监听器
        jComboBox1.setFont(new java.awt.Font("宋体", 0, 14));

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "捷达", "桑塔�??", "奥迪" }));
        jComboBox1.addItemListener(e -> {
            // 当选择“添加...”项目时，弹出对话框以输入新的车辆类型，并添加到列表中
            if(e.getStateChange() == ItemEvent.SELECTED&&e.getItem().equals("添加...")){
                String newType = JOptionPane.showInputDialog("请输入新的车辆类型：");
                CarDAO.addCarTyep(newType);
            }
        });
        // 初始化注册日期为当前日期
        {
        Chooser ser1 = Chooser.getInstance();
		Date nowDate = new Date();
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
		String strNowDate = sf.format(nowDate);
		jTextField6.setText(strNowDate);
		ser1.register(jButton1,jTextField6);
        }

        
        // 设置按钮背景色、字体、图标以及边框等样式
        jButton1.setBackground(new java.awt.Color(255, 255, 255));
        jButton1.setFont(new java.awt.Font("宋体", 0, 14)); // 设置字体为宋体，字号14
        jButton1.setIcon(new javax.swing.ImageIcon("image\\date.png")); // 设置按钮图标
        jButton1.setAlignmentX(0.5F); // 设置按钮的水平对齐方式
        jButton1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); // 设置按钮边框为黑色
        jButton1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); // 设置鼠标指针为手型
        jButton1.setDefaultCapable(false); // 设置按钮不可作为默认按钮
        jButton1.setMargin(new java.awt.Insets(0, 0, 0, 0)); // 设置按钮内边距为0
        // 注册按钮点击事件处理方法
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        // 设置下拉框字体和初始选项
        jComboBox2.setFont(new java.awt.Font("宋体", 0, 14)); // 设置字体
        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "可用", "维修" })); // 设置下拉选项

        // 设置按钮字体和点击事件处理方法
        jButton2.setFont(new java.awt.Font("宋体", 0, 14)); // 设置字体
        jButton2.setText(""); // 设置按钮文本为空
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
            	closeJFrame(); // 注册点击事件处理方法，关闭框架
            }
        });

        // 设置保存按钮的文本、工具提示和点击事件处理方法
        jButton3.setFont(new java.awt.Font("宋体", 0, 14)); // 设置字体
        jButton3.setText("保存"); // 设置按钮文本
        jButton3.setToolTipText("保存"); // 设置工具提示文本
        jButton3.addActionListener(new java.awt.event.ActionListener(){
        	@Override
			public void actionPerformed(java.awt.event.ActionEvent evt){
        		// 实例化CarEntity对象，并设置其属性值
        		CarEntity car = new CarEntity();
            	//car.setId(Integer.parseInt(jTextField1.getText())); // 设置ID，此处代码暂未使用
            	car.setNumber(jTextField2.getText()); // 设置车牌号
            	car.setXinghao(jTextField3.getText()); // 设置型号
            	car.setType(jComboBox1.getSelectedItem().toString()); // 设置类型
            	car.setF_number(jTextField4.getText()); // 设置发动机号
            	car.setJ_number(jTextField5.getText()); // 设置车架号
            	// 将文本框中的内容转换为Date类型
            	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				Date date1;
				try {
					date1 = sdf.parse(jTextField6.getText());
					car.setSelltime(date1); // 设置销售日期
				} catch (ParseException e1) {
					e1.printStackTrace(); // 捕获并处理解析异常
				}

            	car.setState(jComboBox2.getSelectedItem().toString()); // 设置状态
            	car.setInf(jTextField7.getText()); // 设置信息
            	// 调用CarDAO的save方法保存CarEntity对象
            	CarDAO.save(car);
            	// 更新表格内容
				ArrayList<CarEntity> list = CarDAO.findAll(); // 从DAO获取所有实体
				CarManagePanel.data.clear(); // 清空数据
				for(CarEntity temp : list){
					Vector<String> dataline = new Vector<String>();
					dataline.add(Integer.toString(temp.getId()));
					dataline.add(temp.getNumber());
					dataline.add(temp.getXinghao());
					dataline.add(temp.getType());
					dataline.add(temp.getF_number());
					dataline.add(temp.getJ_number());
					dataline.add(temp.getSelltime().toString());
					dataline.add(temp.getState());
					dataline.add(temp.getInf());
					CarManagePanel.data.add(dataline); // 添加数据行
				}
				CarManagePanel.table.updateUI(); // 更新表格UI
				closeJFrame(); // 关闭框架
        	}
        });

        // 设置 jTextField1 的字体、对齐方式、边距和边框
        jTextField1.setFont(new java.awt.Font("宋体", 0, 14)); // 设置字体为宋体，大小为14
        jTextField1.setAlignmentX(0.0F); // 设置对齐方式
        jTextField1.setMargin(new java.awt.Insets(0, 0, 0, 0)); // 设置边距为0
        jTextField1.setBorder(new MatteBorder(0, 0, 1, 0, Color.DARK_GRAY)); // 设置下边框为暗灰色
        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
            	// jTextField1 的动作事件处理
            }
        });

        // 类似地，设置 jTextField2 的属性和动作事件处理
        jTextField2.setFont(new java.awt.Font("宋体", 0, 14));
        jTextField2.setAlignmentX(0.0F);
        jTextField2.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jTextField2.setBorder(new MatteBorder(0, 0, 1, 0, Color.DARK_GRAY));
        jTextField2.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField2ActionPerformed(evt); // 自定义的 jTextField2 动作事件处理方法
            }
        });

        // 重复上述过程为 jTextField3 到 jTextField7 设置属性和动作事件处理
        jTextField3.setFont(new java.awt.Font("宋体", 0, 14));
        jTextField3.setAlignmentX(0.0F);
        jTextField3.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jTextField3.setBorder(new MatteBorder(0, 0, 1, 0, Color.DARK_GRAY));
        jTextField3.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField3ActionPerformed(evt);
            }
        });

        jTextField4.setFont(new java.awt.Font("宋体", 0, 14));
        jTextField4.setAlignmentX(0.0F);
        jTextField4.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jTextField4.setBorder(new MatteBorder(0, 0, 1, 0, Color.DARK_GRAY));
        jTextField4.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField4ActionPerformed(evt);
            }
        });

        jTextField5.setFont(new java.awt.Font("宋体", 0, 14));
        jTextField5.setAlignmentX(0.0F);
        jTextField5.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jTextField5.setBorder(new MatteBorder(0, 0, 1, 0, Color.DARK_GRAY));
        jTextField5.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField5ActionPerformed(evt);
            }
        });

        jTextField6.setFont(new java.awt.Font("宋体", 0, 14));
        jTextField6.setAlignmentX(0.0F);
        jTextField6.setBorder(new MatteBorder(0, 0, 1, 0, Color.DARK_GRAY));
        jTextField6.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jTextField6.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField6ActionPerformed(evt);
            }
        });

        jTextField7.setFont(new java.awt.Font("宋体", 0, 14));
        jTextField7.setAlignmentX(0.0F);
        jTextField7.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jTextField7.setBorder(new MatteBorder(0, 0, 1, 0, Color.DARK_GRAY));
        jTextField7.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField7ActionPerformed(evt);
            }
        });


        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(11, 11, 11)
                                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(8, 8, 8))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(0, 2, Short.MAX_VALUE)
                                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGap(10, 10, 10))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(169, 169, 169)
                                .addComponent(jButton3)
                                .addGap(32, 32, 32)
                                .addComponent(jButton2)))
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            /**
             * 此代码段定义了一个基于javax.swing.GroupLayout的UI布局。它主要包含了多个输入组件（如文本字段和组合框）以及两个按钮，
             * 所有这些组件都是通过GroupLayout进行布局管理的。布局设计考虑了对齐方式和组件之间的间距，以提供一个清晰、有序的用户界面。
             *
             * 该布局不直接包含方法定义，它是作为UI界面的一部分进行编排的。在整体应用中，它可能会包含在某个类的initComponents()方法中，
             * 该方法负责初始化用户界面的所有组件和布局。
             */
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(23, 23, 23) // 添加水平间距
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) // 垂直对齐组件
                                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(18, 18, 18) // 添加垂直间距
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) // 开始一个新的布局组
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) // 垂直对齐方式
                                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) // 垂直对齐方式
                                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(18, 18, Short.MAX_VALUE) // 添加垂直间距
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) // 开始一个新的布局组
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) // 垂直对齐方式
                                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) // 垂直对齐方式
                                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) // 垂直对齐方式
                                    .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(18, 18, Short.MAX_VALUE) // 添加垂直间距
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) // 垂直对齐组件
                                .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE) // 调整组件之间的间距
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) // 垂直对齐两个按钮
                                .addComponent(jButton2)
                                .addComponent(jButton3))
                            .addGap(19, 19, 19)) // 添加最后的垂直间距
        );
        //设置JTextField边框
    	jTextField1.setBorder(new MatteBorder(0, 0, 1, 0, Color.DARK_GRAY));
    	jTextField2.setBorder(new MatteBorder(0, 0, 1, 0, Color.DARK_GRAY));
    	jTextField3.setBorder(new MatteBorder(0, 0, 1, 0, Color.DARK_GRAY));
    	jTextField4.setBorder(new MatteBorder(0, 0, 1, 0, Color.DARK_GRAY));
    	jTextField5.setBorder(new MatteBorder(0, 0, 1, 0, Color.DARK_GRAY));
    	jTextField6.setBorder(new MatteBorder(0, 0, 1, 0, Color.DARK_GRAY));
    	jTextField7.setBorder(new MatteBorder(0, 0, 1, 0, Color.DARK_GRAY));
        
        this.getContentPane().setBackground(Color.WHITE);
        pack();
        Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();//获取屏幕尺寸对象
 		Dimension myframe=this.getSize();//获取当前窗体的尺寸对�??
 		int w=(screen.width-myframe.width)/2;//水平位置
 		int h=(screen.height-myframe.height-300)/2;//垂直位置
 		setLocation(w,h);
        setVisible(true);
    }// </editor-fold>//GEN-END:initComponents
    public void closeJFrame(){
    	this.dispose();
    }


    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField1ActionPerformed

    private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField2ActionPerformed

    private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField3ActionPerformed

    private void jTextField4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField4ActionPerformed

    private void jTextField5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField5ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField5ActionPerformed

    private void jTextField6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField6ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField6ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jTextField7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField7ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField7ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton2ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
   // private Chooser ser = Chooser.getInstance();
    // End of variables declaration//GEN-END:variables
}
